package com.party.mobile.web.controller.file;

import com.alibaba.fastjson.JSONObject;
import com.party.core.model.file.ImgResource;
import com.party.core.service.file.IImgResourceService;
import com.party.mobile.web.dto.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 图片资源
 */
@Controller
@RequestMapping(value = "/file/img")
public class ImgResourceController {
    @Autowired
    IImgResourceService imgResourceService;


    /**
     * 保存
     *
     * @param imgs
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/api/save")
    public AjaxResult save(String imgs) {
        List<ImgResource> imgResources = JSONObject.parseArray(imgs, ImgResource.class);
        for (ImgResource img : imgResources) {
            imgResourceService.insert(img);
        }
        return AjaxResult.success();
    }

}
